package com.jeespring.aop.dynamicproxy.cglib;

import org.springframework.cglib.proxy.Enhancer;

/**
 * @description CglibProxy
 * @author 张朝阳
 * @date 2021/4/8 18:08
 */
public class CglibProxy {
    public static void main(String[] args) {
        Enhancer enhancer = new Enhancer();

        enhancer.setSuperclass(UserServiceImpl.class);
        enhancer.setCallback(new MethodInterceptorImpl());

        UserServiceImpl userProxyUser = (UserServiceImpl)enhancer.create();
        String zhangc = userProxyUser.addUser("zhangc");
        System.out.println(zhangc);
    }
}
